﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class GatheringMap : EntityConfigurationBase<Gathering>
    {
        public GatheringMap()
        {
            this.Property(p => p.Drawee).HasMaxLength(20).IsRequired();
            this.Property(p => p.GatheringBank).HasMaxLength(20).IsRequired();
            this.Property(p => p.Bank).HasMaxLength(30).IsRequired();
            this.Property(p => p.Money).HasPrecision(18, 2);
            this.Property(p => p.SerialNumber).HasMaxLength(100).IsRequired();
            this.Property(p => p.Remark).HasMaxLength(200).IsOptional();
            this.Property(p => p.SubmiterName).HasMaxLength(20).IsRequired();
            this.Property(p => p.PayeeName).HasMaxLength(20);


            this.HasRequired(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
            this.HasRequired(p => p.Submiter).WithMany().HasForeignKey(f => f.SubmiterId);
            this.HasOptional(p => p.Payee).WithMany().HasForeignKey(f => f.PayeeId);
        }
    }
}
